package com.ruoyi.system.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.vo.TbDeviceAndInfoDetailVO;
import com.ruoyi.system.domain.vo.TbDeviceVO;
import com.ruoyi.system.mapper.TbDeviceInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbDeviceMapper;
import com.ruoyi.system.domain.TbDevice;
import com.ruoyi.system.service.ITbDeviceService;

/**
 * 设备信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-23
 */
@Service
public class TbDeviceServiceImpl implements ITbDeviceService {
    @Autowired
    private TbDeviceMapper tbDeviceMapper;


    @Autowired
    private TbDeviceInfoMapper  deviceInfoMapper;

    /**
     * 查询设备信息
     *
     * @param id 设备信息主键
     * @return 设备信息
     */
    @Override
    public TbDevice selectTbDeviceById(Long id) {
        return tbDeviceMapper.selectTbDeviceById(id);
    }

    /**
     * 查询设备信息列表
     *
     * @param tbDevice 设备信息
     * @return 设备信息
     */
    @Override
    public List<TbDevice> selectTbDeviceList(TbDevice tbDevice) {
        return tbDeviceMapper.selectTbDeviceList(tbDevice);
    }

    /**
     * 新增设备信息
     *
     * @param tbDevice 设备信息
     * @return 结果
     */
    @Override
    public int insertTbDevice(TbDevice tbDevice) {
        tbDevice.setCreateTime(DateUtils.getNowDate());
        return tbDeviceMapper.insertTbDevice(tbDevice);
    }

    /**
     * 修改设备信息
     *
     * @param tbDevice 设备信息
     * @return 结果
     */
    @Override
    public int updateTbDevice(TbDevice tbDevice) {
        tbDevice.setUpdateTime(DateUtils.getNowDate());
        return tbDeviceMapper.updateTbDevice(tbDevice);
    }

    /**
     * 批量删除设备信息
     *
     * @param ids 需要删除的设备信息主键
     * @return 结果
     */
    @Override
    public int deleteTbDeviceByIds(Long[] ids) {
        return tbDeviceMapper.deleteTbDeviceByIds(ids);
    }

    /**
     * 删除设备信息信息
     *
     * @param id 设备信息主键
     * @return 结果
     */
    @Override
    public int deleteTbDeviceById(Long id) {
        return tbDeviceMapper.deleteTbDeviceById(id);
    }

    @Override
    public List<TbDeviceVO> selectTbDeviceLis(TbDeviceVO vo) {
        return tbDeviceMapper.selectTbDeviceLis(vo);
    }

    @Override
    public R<TbDeviceVO> selectTbDeviceInfoById(Long id) {

        return R.ok(tbDeviceMapper.selectTbDeviceInfoById( id));
    }

    @Override
    public TbDevice selectTbDeviceByDevSn(String devSn) {
        return tbDeviceMapper.selectTbDeviceByDevSn(devSn);
    }

    @Override
    public R<TbDeviceAndInfoDetailVO> selectTbDeviceInfosById(Long id) {
        return R.ok(deviceInfoMapper.selectTbDeviceInfosById(id));
    }
}
